
/******************************************************************************
*@file  : main.c
*@brief : main program
******************************************************************************/

#include "main.h" 
#include "app.h" 

extern NORFLASH_ParamTypeDef NORFLASH_param;

/******************************************************************************
*@brief : main program
*@param : none
*@return: none
******************************************************************************/
int main(void)
{
    uint32_t rc32kVal;
    int tick=0;
	HAL_Init();  
    SystemClock_Config(SYSCLK_180M_SRC_RC64M,RCC_PCLK1_DIV_1,RCC_PCLK2_DIV_1);  
    HAL_Init_Ex();   
    
    BSP_UART_Init(UART1);  
	printfS("\r\n\r\n====== ACM32F42X MCU is runing ======\r\nSysCoreClk: %dHz, HCLK:%dHz\r\nPCLK1:%dHz, PCLK2:%dHz\r\n\r\n",
        g_SystemCoreClock, HAL_RCC_GetHCLKFreq(),HAL_RCC_GetPCLK1Freq(),HAL_RCC_GetPCLK2Freq()); 

    if(HAL_NORFLASH_GetRC32KVal(&rc32kVal)==HAL_OK)
    {
        printfS("RC32K TRIM VALUE:%d\r\n",rc32kVal);
    }
    else
    {
        printfS("RC32K TRIM VALUE Invalid\r\n");
    }
    
	//while(1);
	
    HAL_NORFLASH_Init();
    printfS("FLASH SIZE: %dKB",NORFLASH_param.chipSize);
    APP_Test();  
    
    SN_Test();
    
    while(1)
    {
        HAL_Delay(5000);
        printfS("tick %d\r\n",tick++);
        APP_Test(); 
//        if(tick==10)
//        {
//            HAL_NORFLASH_EraseBootFlag();
//            printfS("erase boot flag\r\n");
//        }
    }
}














